﻿using Comm;
using Kinlo.UI.Main.View;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;

namespace Kinlo.UI.Main
{
    /// <summary>
    /// App.xaml 的交互逻辑
    /// </summary>
    public partial class App : Application
    {
        Mutex mutex;
        protected override void OnStartup(StartupEventArgs e)
        {
            // base.OnStartup(e);
            bool testResult = false;
            mutex = new Mutex(true, "KINLO", out testResult);
            if (testResult)
            {
                Application.Current.ShutdownMode = ShutdownMode.OnExplicitShutdown; 
                base.OnStartup(e);
            }
            else
            {
                MessageBox.Show("程序已运行,请勿重复运行", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
                Environment.Exit(1);
                return;
            }
        }

        protected override void OnExit(ExitEventArgs e)
        {
            Logger.Info("系统关闭",false);
            base.OnExit(e);

        }
    }
}
